package com.ndp.fb.rdb.api;

import com.ndp.fb.rdb.model.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by infi.he on 2016/4/18.
 */
public interface EcTemplateMaterielRdbService {
    EcTemplateMateriel findEcTemplateMaterielById(Long materialId);

    EcTemplateMaterielFeedExt findEcTemplateMaterielFeedExtById(Long materialId);

    Long save(EcTemplateMateriel ecTemplateMateriel);

    List<EcTemplateMateriel> findByFeedId(Long feedId);

    List<EcTemplateMateriel> findAll();

    List<EcTemplateMateriel> findAllCreated();
    List<EcTemplateMateriel> findAllByStatus(int status);

    List<EcTemplateMateriel> findByWeFeedIdAndNames(String feedId, List<String> creativeTemplate);

    List<EcTemplateMateriel> findByIds(Object[] objects);

    EcTemplateMaterielExt findExtById(Long id);

    Pager<EcTemplateMateriel> findPagerByName(Integer feedId,User user, String name, List<String> creativeStatus, List<Map<String, List<String>>> categoryList, Integer firstResult, Integer sizeNo, String order);

    Pager<EcTemplateMateriel> findPagerByTag(Integer feedId,User user, Long tagId, List<String> creativeStatus, List<Map<String, List<String>>> categoryList, Integer firstResult, Integer sizeNo, String order);

    void updateProductCountAndCreatedImgNum(int size, Long createdImgNo, Long materialId);

    void updateCreatedImgNum(Long createdImgNo, Long materialId);

    void updateCreatedStatus(Integer s, Date createDate, Long materialId);
    void updateCreatedStatus(Integer s, Long materialId);

    void delete(Long orgId, Long id);

    EcTemplate findEcTemplateByMaterielId(Long materialId);

    void updateMaterielCodeAndThumbnailAndMaterielContext(String materialCode, String thumbnail,String html, Long id);

    EcTemplateMateriel findByNameAndOrgId(String name, Long orgId);

    void updateName(String name, Long ecTemplateMaterielId);

    void updateNameAndTemplateId(String name, Long templateId, Long ecTemplateMaterielId);

    void updateTemplateCode(String templateCode,Long ecTemplateMaterielId);

    void updateCreatedStatusAndNewFeedUrl(int type, Date date, String descScPath, Long materialId);

    /**
     * 按照分类查询模板，仅支持2层结构
     * @param feedId
     * @param type
     * @return
     */
    List<EcTemplateMateriel> findByFeedIdAndCreativeType(Long feedId,int type);
    
    List<Long> findCategoryIdByMaterielId(Long id);

    List<EcTemplateMateriel> findEcTemplateMaterielCanUseCreateAd(Long feedId);

    /**
     * 用于通过物料模板ID查询此物料使用的元素以及模板自身属性的联合查询时使用，
     *
     * @return 查询结果，比如物料模板1使用了轮播结构，DesktopFeed版位，并且采用FreeShipping的元素等
     */
    List<EcTemplateMaterielAndElementCategory> findCategoryAndElement(Long ecTemplateMaterielId);
}
